package com.game.majiang.algorithm;

import java.util.Comparator;

public class PaperSortByNum implements Comparator<PaperCard>{
	public int orderBy = 0;// 升序  1 降

	public PaperSortByNum(){
		
	}
	public PaperSortByNum(int order){
		this.orderBy = order;
		
	}
	@Override
	public int compare(PaperCard o1, PaperCard o2) {
		int temp_1 = o1.getNum();
		int temp_2 = o2.getNum();
		
		
		if(this.orderBy == 0) {
			if(temp_1 > temp_2) {
				return 1;
			} else if(temp_1 < temp_2) {
				return -1;
			} else {
				if(o1.getType() < o2.getType()) {
					return 1;
				} else if(o1.getType() > o2.getType()){
					return -1;
				}
				
			}
		} else {
			if(temp_1 > temp_2) {
				return -1;
			} else if(temp_1 < temp_2) {
				return 1;
			}else {
				if(o1.getType() < o2.getType()) {
					return -1;
				} else if(o1.getType() > o2.getType()){
					return 1;
				}
				
			}
		}
		return 0;
	}

}
